/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-09-27 17:00:47
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-09-27 17:14:29
 * @FilePath: \adminstration\src\Pages\Front\Common\Other\index.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import dayjs from 'dayjs'
import { Tooltip } from 'antd'
import { useNavigate } from 'react-router-dom'
import { useState, useEffect } from 'react'
import { ConsoleSqlOutlined, LogoutOutlined } from '@ant-design/icons'

// 时间
export const Time = ({ one, two }) => {
    const [now, setNow] = useState(dayjs())
    useEffect(() => {
        const t = setInterval(() => setNow(dayjs()), 1000)
        return () => clearTimeout(t)
    }, [])
    return (
        <>
            <span className="one">{now.format(one)}</span>
            <span className="two">{now.format(two)}</span>
        </>
    )
}

// 操作项
export const Options = ({ one, two }) => {
    const Navigate = useNavigate()
    return (
        <>
            <Tooltip title="进入后台" zIndex={10000} onClick={() => Navigate('/Admin')}>
                <ConsoleSqlOutlined style={{ color: 'white', fontSize: 20 }} />
                <span>{one}</span>
            </Tooltip>
            <Tooltip title="退出登录" zIndex={10000} onClick={() => Navigate('/')}>
                <LogoutOutlined style={{ color: 'white', fontSize: 20 }} />
                <span>{two}</span>
            </Tooltip>
        </>
    )
}
